package com.architecture.core.entity;

import javax.persistence.*;
import java.util.List;

/**
 * 区分权限类型
 * Created with IntelliJ IDEA.
 * User: aguang
 * Date: 13-1-19
 * Time: 下午8:20
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "CORE_CATEGORY")
public class Category extends BaseEntity {

    @Column(name = "CATEGORY_TYPE",unique = true)
    private int type;                       //权限类型/模块，如：1.front web;2.back web;3.webservice;等

    @Column(name = "CATEGORY_NAME")
    private String name;

//    @ManyToMany(fetch = FetchType.LAZY,targetEntity = Permission.class,cascade = CascadeType.ALL)
//    @JoinTable(name = "EX_PERMISSION_TYPE_PERMISSION",joinColumns = {@JoinColumn(name = "PERMISSION_TYPE_ID")},inverseJoinColumns = {@JoinColumn(name = "PERMISSION_ID")})
//    private List<Permission> permissionList;
//
//    @ManyToMany(fetch = FetchType.LAZY,targetEntity = PermissionRole.class,cascade = CascadeType.ALL)
//    @JoinTable(name = "EX_PERMISSION_TYPE_PERMISSION_ROLE",joinColumns = {@JoinColumn(name = "PERMISSION_TYPE_ID")},inverseJoinColumns = {@JoinColumn(name = "PERMISSION_ROLE_ID")})
//    private List<PermissionRole> permissionRoleList;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "category", targetEntity = Permission.class, cascade = CascadeType.ALL)
    private List<Permission> permissionList;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "category", targetEntity = PermissionRole.class, cascade = CascadeType.ALL)
    private List<PermissionRole> permissionRoleList;

    @ManyToMany(fetch = FetchType.LAZY, targetEntity = User.class, cascade = CascadeType.ALL, mappedBy = "categoryList")
    private List<User> userList;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public List<Permission> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<Permission> permissionList) {
        this.permissionList = permissionList;
    }

    public List<PermissionRole> getPermissionRoleList() {
        return permissionRoleList;
    }

    public void setPermissionRoleList(List<PermissionRole> permissionRoleList) {
        this.permissionRoleList = permissionRoleList;
    }

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }
}
